package com.qzdsoft.erpcloud.service.sys.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.qzdsoft.erpcloud.domain.sys.SysRoleMenu;
import com.qzdsoft.erpcloud.mapper.sys.SysRoleMenuMapper;
import com.qzdsoft.erpcloud.service.sys.SysRoleMenuService;
import com.qzdsoft.vo.Response;

/**
 * Created by Admin
 */
@Service
public class SysRoleMenuServiceImpl implements SysRoleMenuService {

    @Autowired
    private SysRoleMenuMapper sysRoleMenuMapper;

    @Override
    public SysRoleMenu selectById(Integer id) {
        return sysRoleMenuMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<SysRoleMenu> selectByRoleId(Integer roleId) {
        return sysRoleMenuMapper.selectByRoleId(roleId);
    }

    @Override
    public Response del(Integer id) {
        sysRoleMenuMapper.deleteByPrimaryKey(id);
        return Response.success("删除成功！");
    }

    /**
     *
     * @param roleId
     * @param menuIds
     * @return
     */
    @Override
    public Response save(Integer roleId, List<Integer> menuIds) {
        sysRoleMenuMapper.deleteBatchNotIn(roleId, menuIds);
        sysRoleMenuMapper.insertBatch(roleId, menuIds);
        return Response.success("保存成功!");
    }


}
